﻿IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'P_DeleteUser')
	BEGIN
		DROP  Procedure  [esf_sso].P_DeleteUser
	END

GO

CREATE Procedure [esf_sso].P_DeleteUser
	@pPersonID				BIGINT
AS

	DELETE esf_sso.Person_Location
	WHERE PersonID = @pPersonID

	DELETE esf_sso.UserSessionLog
	WHERE UserPersonID = @pPersonID

	DELETE esf_sso.User_BasicReference_Values
	WHERE UserPersonID = @pPersonID

	DELETE esf_sso.User_BasicReference
	WHERE UserPersonID = @pPersonID
	
	DELETE [esf_sso].[User]
	WHERE [PersonID] = @pPersonID
	
	DELETE esf_sso.Person
	WHERE ID = @pPersonID

GO